<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>习题生成器</title>
    <link rel="stylesheet" href="css/css.css" media="all">

</head>
<body style="width: 900px">
<div id="show">
    选择题目：
    <select id="select">
        <option value="">全部</option>
        <option value="counter" ref="one/shuxue/counter.html">计数器（一年级）</option>
        <option value="addition3" ref="one/shuxue/addition3.html">3个数计算（一年级）</option>
        <option value="shizi" ref="one/yuwen/shizi.html">识字练习（一年级）</option>
        <option value="xiezi" ref="one/yuwen/shizi.html">写字练习（一年级）</option>
    </select>
    数量：<input type="text" id="num" placeholder="数量" value="20">
    <button id="add">增加题目</button>
    <button id="link">跳转到专题</button>
    <div id="list">

    </div>
    <button id="go">生成题目</button>
</div>

<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/zi.js"></script>
<script src="js/quest.js"></script>
<script src="js/xxn.js"></script>


<script>
    $(function () {
        var map = [];

        $("#link").on("click", function () {

            var ref = $("#select").find("option:selected").attr('ref')
            if (ref) window.open(ref);
        });
        $("#go").on("click", function () {
            if (map.length == 0) return;
            $("#show").html("");
            for (var i in map) {
                $("#show").append("<div class='title'><h2>" + map[i].title + "</h2></div>")
                $("#show")[map[i].name](map[i].num);

            }
        });

        $("#add").on("click", function () {
            var name = $("#select").val();
            var num = $("#num").val();
            if (num <= 0) return;
            if (name !== '') {
                var t = {};
                t.name = name;
                t.num = num;
                t.title = $("#select").find("option:selected").text();
                map.push(t);
                $("#list").append("<div>" + t.title + "(" + t.num + ")</div>");
            } else {
                $("#select").find("option").each(function (e) {
                    if ($(this).val()) {
                        var t = {};
                        t.name = $(this).attr("value");
                        t.title = $(this).html();
                        t.num = num;
                        map.push(t);
                        $("#list").append("<div>" + $(this).html() + "(" + t.num + ")</div>");
                    }
                })
            }

        })
    })
</script>
</body>
</html>